package org.gap.service;

import java.util.List;
import java.util.Set;

import org.gap.domain.CodesPostaux;
import org.gap.domain.EtablissementsBancaires;
import org.gap.domain.Pays;

import org.junit.Test;

import org.junit.runner.RunWith;

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.beans.factory.support.DefaultListableBeanFactory;

import org.springframework.context.ApplicationContext;

import org.springframework.mock.web.MockHttpServletRequest;

import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestExecutionListeners;

import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import org.springframework.test.context.support.DependencyInjectionTestExecutionListener;
import org.springframework.test.context.support.DirtiesContextTestExecutionListener;

import org.springframework.test.context.transaction.TransactionalTestExecutionListener;

import org.springframework.transaction.annotation.Transactional;

import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.RequestScope;
import org.springframework.web.context.request.ServletRequestAttributes;
import org.springframework.web.context.request.SessionScope;

/**
 * Class to run the service as a JUnit test. Each operation in the service is a separate test.
 *
 */

@RunWith(SpringJUnit4ClassRunner.class)
@TestExecutionListeners({
		DependencyInjectionTestExecutionListener.class,
		DirtiesContextTestExecutionListener.class,
		TransactionalTestExecutionListener.class })
@ContextConfiguration(locations = {
		"file:./resources/GAP_v2-security-context.xml",
		"file:./resources/GAP_v2-service-context.xml",
		"file:./resources/GAP_v2-dao-context.xml",
		"file:./resources/GAP_v2-web-context.xml" })
@Transactional
public class PaysServiceTest {

	/**
	 * The Spring application context.
	 *
	 */
	@SuppressWarnings("unused")
	private ApplicationContext context;

	/**
	 * The service being tested, injected by Spring.
	 *
	 */
	@Autowired
	protected PaysService service;

	/**
	 * Instantiates a new PaysServiceTest.
	 *
	 */
	public PaysServiceTest() {
		setupRequestContext();
	}

	/**
	 * Operation Unit Test
	 * Save an existing CodesPostaux entity
	 * 
	 */
	@Test
	public void savePaysCodesPostauxes() {
		// TODO: JUnit - Populate test inputs for operation: savePaysCodesPostauxes 
		String pppPays = null;
		CodesPostaux related_codespostauxes = new org.gap.domain.CodesPostaux();
		Pays response = null;
		response = service.savePaysCodesPostauxes(pppPays, related_codespostauxes);
		// TODO: JUnit - Add assertions to test outputs of operation: savePaysCodesPostauxes
	}

	/**
	 * Operation Unit Test
	 * Load an existing Pays entity
	 * 
	 */
	@Test
	public void loadPayss() {
		Set<Pays> response = null;
		response = service.loadPayss();
		// TODO: JUnit - Add assertions to test outputs of operation: loadPayss
	}

	/**
	 * Operation Unit Test
	 * Return a count of all Pays entity
	 * 
	 */
	@Test
	public void countPayss() {
		Integer response = null;
		response = service.countPayss();
		// TODO: JUnit - Add assertions to test outputs of operation: countPayss
	}

	/**
	 * Operation Unit Test
	 * Return all Pays entity
	 * 
	 */
	@Test
	public void findAllPayss() {
		// TODO: JUnit - Populate test inputs for operation: findAllPayss 
		Integer startResult = 0;
		Integer maxRows = 0;
		List<Pays> response = null;
		response = service.findAllPayss(startResult, maxRows);
		// TODO: JUnit - Add assertions to test outputs of operation: findAllPayss
	}

	/**
	 * Operation Unit Test
	 * Save an existing Pays entity
	 * 
	 */
	@Test
	public void savePays() {
		// TODO: JUnit - Populate test inputs for operation: savePays 
		Pays pays = new org.gap.domain.Pays();
		service.savePays(pays);
	}

	/**
	 * Operation Unit Test
	 */
	@Test
	public void findPaysByPrimaryKey() {
		// TODO: JUnit - Populate test inputs for operation: findPaysByPrimaryKey 
		String pppPays_1 = null;
		Pays response = null;
		response = service.findPaysByPrimaryKey(pppPays_1);
		// TODO: JUnit - Add assertions to test outputs of operation: findPaysByPrimaryKey
	}

	/**
	 * Operation Unit Test
	 * Delete an existing EtablissementsBancaires entity
	 * 
	 */
	@Test
	public void deletePaysEtablissementsBancaireses() {
		// TODO: JUnit - Populate test inputs for operation: deletePaysEtablissementsBancaireses 
		String pays_pppPays = null;
		String related_etablissementsbancaireses_etbPays = null;
		Integer related_etablissementsbancaireses_etbEtablissement = 0;
		Pays response = null;
		response = service.deletePaysEtablissementsBancaireses(pays_pppPays, related_etablissementsbancaireses_etbPays, related_etablissementsbancaireses_etbEtablissement);
		// TODO: JUnit - Add assertions to test outputs of operation: deletePaysEtablissementsBancaireses
	}

	/**
	 * Operation Unit Test
	 * Save an existing EtablissementsBancaires entity
	 * 
	 */
	@Test
	public void savePaysEtablissementsBancaireses() {
		// TODO: JUnit - Populate test inputs for operation: savePaysEtablissementsBancaireses 
		String pppPays_2 = null;
		EtablissementsBancaires related_etablissementsbancaireses = new org.gap.domain.EtablissementsBancaires();
		Pays response = null;
		response = service.savePaysEtablissementsBancaireses(pppPays_2, related_etablissementsbancaireses);
		// TODO: JUnit - Add assertions to test outputs of operation: savePaysEtablissementsBancaireses
	}

	/**
	 * Operation Unit Test
	 * Delete an existing CodesPostaux entity
	 * 
	 */
	@Test
	public void deletePaysCodesPostauxes() {
		// TODO: JUnit - Populate test inputs for operation: deletePaysCodesPostauxes 
		String pays_pppPays_1 = null;
		String related_codespostauxes_cdpPays = null;
		String related_codespostauxes_cdpCodePostal = null;
		String related_codespostauxes_cdpNInsee = null;
		String related_codespostauxes_cdpLocalite = null;
		Pays response = null;
		response = service.deletePaysCodesPostauxes(pays_pppPays_1, related_codespostauxes_cdpPays, related_codespostauxes_cdpCodePostal, related_codespostauxes_cdpNInsee, related_codespostauxes_cdpLocalite);
		// TODO: JUnit - Add assertions to test outputs of operation: deletePaysCodesPostauxes
	}

	/**
	 * Operation Unit Test
	 * Delete an existing Pays entity
	 * 
	 */
	@Test
	public void deletePays() {
		// TODO: JUnit - Populate test inputs for operation: deletePays 
		Pays pays_1 = new org.gap.domain.Pays();
		service.deletePays(pays_1);
	}

	/**
	 * Autowired to set the Spring application context.
	 *
	 */
	@Autowired
	public void setContext(ApplicationContext context) {
		this.context = context;
		((DefaultListableBeanFactory) context.getAutowireCapableBeanFactory()).registerScope("session", new SessionScope());
		((DefaultListableBeanFactory) context.getAutowireCapableBeanFactory()).registerScope("request", new RequestScope());
	}

	/**
	 * Sets Up the Request context
	 *
	 */
	private void setupRequestContext() {
		MockHttpServletRequest request = new MockHttpServletRequest();
		ServletRequestAttributes attributes = new ServletRequestAttributes(request);
		RequestContextHolder.setRequestAttributes(attributes);
	}
}
